package com.example.client;

import com.example.service.MyService;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * @Description
 * @Author 26233
 * @Create 2021-10-31 17:34:15
 */

public class Main {
    public static void main(String[] args) {

        try {
            // 实际上是代理进行远程请求
            MyService service = (MyService) Naming.lookup("rmi://localhost:9999/myservice");
            String zs = service.getName("zs");
            System.out.println("zs = " + zs);
        } catch (NotBoundException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }

    }
}
